// 引入axios（axios进行了二次封装）
import request from '@/utils/request'

//登录 url：/login method：post
export function login(data){
  return request({
    url:'/login',
    method:'post',
    data
  })
}

//获取登录验证码 url：/code method：get
export function getCode(username){
  return request({
    url:'/code',
    method:'get',
    params: {
      username: username
    }
  })
}

//获取修改密码验证码
export function getPwdCode(username){
  return request({
    url:'/user/code',
    method:'get',
    params: {
      username: username
    }
  })
}

//注册 url：/register method：post
export function register(data){
  return request({
    url:'/register',
    method:'post',
    data
  })
}

//获取当前登录的用户信息
export function getInfo() {
  return request({
    url: '/user/getUserInfo',
    method: 'get',
  })
}

//退出登录
export function logout() {
  return request({
    url: '/logout',
    method: 'get'
  })
}

//更新用户信息
export function updateUser(data){
  return request({
    url:'/user/updateUserInfo',
    method:'put',
    data
  })
}

//修改用户密码
export function updateUserPassword(data){
  return request({
    url:'/user/updatePassword',
    method:'put',
    data
  })
}

//忘记密码
export function forgetPassword(data){
  return request({
    url:'/forgetPassword',
    method:'put',
    data
  })
}